<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Login
 *
 * @author alan
 */
require 'BaseDatos.php';
class Login {
    //put your code here
    private $user;
    private $_grup;
    private $_passwd;
    private $_conect=new BaseDatos("localhost", "foro", "root", "");
    public function __construct(){
        
    }
    
    public funtion login($user,$passwd){
        var $urlOK="localhost/index.php";
        var $urlOFF="localhost/unlogin.php";
        var $consulta="SELECT passwd FROM usuaris WHERE (email='".$user."') AND valid='1'";
        $e=$this->conect->consulta($consulta);
        if($passwd==$e["passwd"]){
            $_SESSION["USUSARI"]=$user;
            header("Location: ".$urlOK);}
        else { header("Location: ".$urlOFF);}
        return $e;
    }
    
    public function unLogin(){
        var $urlOK="localhost/index.php";
        unset($_SESSION["USUSARI"]);
        header("Location: localhost/index.php");
        return 0;
    }
  
}

?>
